// 本文件由FirstUI授权予关赛川（手机号：1560  0 515   2   0 5，身份证尾号：   2265 1 9）专用，请尊重知识产权，勿私下传播，违者追究法律责任。
// #ifdef MP
import http from '../common/fui-request'
// #endif
// #ifndef VUE3
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
			// #endif

			// #ifdef VUE3
			import {
				createStore
			} from 'vuex'
			const store = createStore({
				// #endif
				state: {
					//是否登录
					isLogin: uni.getStorageSync("yc_m_token") ? true : false,
					userId:uni.getStorageSync("yc_m_userId")
				},
				mutations: {
					//登录
					login(state, payload) {
						if (payload) {
							console.log("payload",state,payload)
							// state.token = payload.token
							// uni.setStorageSync('yc_m_token',payload.token)
							state.token = payload.user.token
							state.userId = payload.user.user.userId
							uni.setStorageSync('yc_m_token',payload.user.token)
							uni.setStorageSync('yc_m_userId',payload.user.user.userId)
						}
						state.isLogin = true
					},
					//退出登录
					logout(state) {
						state.token = ""
						state.isLogin = false
						uni.removeStorageSync('yc_m_token')
						uni.removeStorageSync('yc_m_userId')
					}
				},
				actions: {

				}
			})

			export default store